import api from "../../utils/api_util";
import baseUtil from "../../utils/base_util";

const app = getApp();
Page({
    data: {
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        integrallist: [],
        //翻页
        pageNumber: 1,
        pageSize: 20,
        hasNext:true,
    },
    onShow: function () {
        this.getMyTeam();
    },
    //团队
    getMyTeam: function () {
        let that = this;
        api.wxRequest.apiRequest(that, api.urls.teamList, {
            method: 'GET',
            data: {
                v: '1.0.0',
                pageSize: that.data.pageSize,
                pageNumber: that.data.pageNumber,
            },
            success: function (res) {

                if(res.data.totalCount > (res.data.pageSize*res.data.currentPage)){
                    that.data.hasNext = true;
                }else {
                    that.data.hasNext = false;
                    console.log('没有了')
                }

                if(res.data.rows && res.data.rows.length > 0){
                    that.data.integrallist = that.data.integrallist.concat(res.data.rows);
                }

                console.log('data:',that.data.integrallist)
                that.setData({
                    integrallist: that.data.integrallist,
                })

            },
        })
    },
    onReachBottom:function (e) {
        let that = this;
        if(that.data.hasNext){
            that.data.pageNumber++;
            that.getMyTeam();
        }
        that.setData({
            pageNumber: that.data.pageNumber,
        })
    }
})